package com.smart.service;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

import com.smart.dao.Page;
import com.smart.dao.PageRequest;
import com.smart.model.Info;
import com.smart.model.InfoCond;
import com.smart.model.InfoViewData;

/**
 * 
 * @author Sunxin
 *
 */
 
@Transactional(readOnly=true)
public interface InfoService extends BaseService<Info, InfoCond, Long>{
	
	@Transactional(readOnly = false)
	@CacheEvict(value="infoCache", allEntries=true)
	void save(Info info);
	
	@Cacheable(value="infoCache", key="#pageRequest.getCacheKeyPart().concat(#cond.getCacheKeyPart())")
	Page<Info> findAll(PageRequest pageRequest, InfoCond cond);
	
	Info findOneNext(Long id);
	
	Info findOnePrev(Long id);
	
	@Cacheable(value="infoCache", key="'infoview-'.concat(#id)")
	InfoViewData getDataForInfoView(Long id);
	
	@Transactional(readOnly = false)
	void updateViewCount(Long id);
	
}
